package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.TaskNotification;
import com.shrcl.engineerprocess.domain.TaskNotificationDAO;
import com.shrcl.engineerprocess.domain.impl.TaskNotificationImpl;
import edu.fudan.langlab.domain.task.TSKTask;
import edu.fudan.mylang.pf.BaseDAOService;
import edu.fudan.mylang.pf.IGenericQuery;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.springframework.stereotype.Service;

@Service("com.shrcl.engineerprocess.domain.TaskNotificationDAO")
public class TaskNotificationDAOImpl extends BaseDAOService<TaskNotification> implements TaskNotificationDAO {
  public TaskNotification create(final Procedure1<? super TaskNotification> init) {TaskNotification taskNotification=TaskNotificationImpl.create(getObjectFactory());
    final Procedure1<TaskNotification> _function = new Procedure1<TaskNotification>() {
        public void apply(final TaskNotification it) {
          init.apply(it);
          it.start();
        }
      };
    TaskNotification _doubleArrow = ObjectExtensions.<TaskNotification>operator_doubleArrow(taskNotification, _function);
    return _doubleArrow;
  }
  
  public TaskNotification getTaskNotificationByTask(final TSKTask tsk) {
    IGenericQuery<TaskNotification> query=getObjectFactory().createGenericQuery(TaskNotification.class,"select e from com.shrcl.engineerprocess.domain.impl.TaskNotificationImpl as e   where ((e.tskTask) = (:tsk)) and  e.active = 1      ").setParameter("tsk",tsk);
    TaskNotification _uniqueResult = query.uniqueResult();
    return _uniqueResult;
  }
}
